Marc,

    This is just to give you a slight idea of what I've been up to. I've
pretty much put together the specs for the what I'm fondly referring to as
"HexEdit". It's going to be the underlying code for the Hex/ASCII editor,
whatever the interface eventually looks or acts like. It's been designed with
the future in mind so that it may eventually be implemented as a multi-part
custom control. It borrows quite a bit of low-level record structure from
TextEdit.

     The great thing about this design is that while it enables us to have a
very powerful Hex editor such as that in ResEdit 2.1 (which isn't the greatest
after all), I don't have to do everything just to get a working alpha version.
What I mean is that since most all attributes concerning the hex edit record
can be individually specified by bit flags, I can just implement those that are
absolutely necessary at first. As we need or want it to grow, the defined bit
flags can then be implemented.

    I've also defined 17 calls that work upon specified HexEdit records. These
all directly correspond to current TextEdit calls. I only have one serious
question. I'd like to be able to use HexEdit within both the Hex/ASCII editor
and the Template editor for hex fields. Unfortunately, this begs the question,
"how?" Will we need to duplicate the HexEdit code into both editors? Or would
it be possible to do something like build HexEdit as a user toolset that the
Hex/ASCII editor installs at startup time? Or it could be a code resource based
user tool that resides within the shell? Or could it be a run time library? Does
ORCA even support RTLs? As you can see, I ask strange questions. :-)

    Now some questions on the Template-driven editor. Do you have any specific
ideas as to how you would like this to work? I've studied the structure of
ResEdit's template editor and I have the specs on building your own templates.
Would you like our editor to use the same type definitions as ResEdit? Or should
we design our own types? I prefer 'byte', 'word', and 'long' to 'HBYT', 'HWRD',
and 'HLNG' as ResEdit uses. But it would be pretty simple to have multiple names
for each type. That way we could use the names we are accustomed to, while
enticing all of those Mac developers to use our product to write IIgs software.
Yeah, right. :-)

This is the parameter block used to create a HexEdit record.

HEParamBlock:
=============

$00 - pCount            Word - Number of parameter fields to follow. Valid
                               values lie in the range from 7 to 13.

$02 - ID                Long - Unique ID for HexEdit records. The application
                               can use it to identify a particular HexEdit
                               record uniquely.

$06 - rect              Rect - Boundary rectangle for the HexEdit record. This
                               rectangle contains the entire record, including
                               its scroll bars, grow box, outline, and line
                               offsets. If the lower-right corner of this
                               rectangle is set to (0,0), HexEdit uses the lower
                               right corner of the window that contains the
                               record as a default.

$0E - procRef           Long - Must be set to NIL.

$12 - flag              Word - Must be set to NULL.

$14 - moreFlags         Word - Must be set to NULL.

$16 - refCon            Long - Reserved for application use.

$1A - hexFlags          Long - Specific HexEdit control flags. Valid values for
                               hexFlags are as follows:

   fNotControl          Bit  31     Must be set to 1.
   fOffsetType          Bits 30-29  Defines the type of byte offsets drawn just
                                    inside the left side of the boundary rect.
                                    00 = Do not draw any offsets
                                    01 = Draw short offsets ($wxyz)
                                    10 = Draw long offsets  ($uvwxyz)
                                    11 = Invalid value
   Reserved             Bit  28     Must be set to 0.
   fNoScroll            Bit  27     Controls user access to scrolling.
                                    0 = Allow scrolling
                                    1 = Do not allow either manual or automatic
                                        scrolling
   fReadOnly            Bit  26     Restricts the text in the record to read-
                                    only (copying from the record is still
                                    allowed).
                                    0 = Editing permited
                                    1 = No editing permitted
   Reserved             Bit  25     Must be set to 0.
   fTabSwitch           Bit  24     Must be set to 0.
   fDrawBounds          Bit  23     Tells HexEdit whether to draw a box around
                                    the edit record, just inside the rect. The
                                    pen for this box is two pixels wide by one
                                    pixel high.
   fDataType            Bits 22-21  Tells HexEdit what kind of data is to be
                                    displayed.
                                    00 = Invalid value
                                    01 = Draw only hex data
                                    10 = Draw only ASCII data
                                    11 = Draw both data types
   fDisableSelection    Bit  20     Controls whether the user can select text.
                                    0 = User can select text.
                                    1 = User cannot select text.
   fNoVertScroll        Bit  19     Tells HexEdit whether to draw a vertical
                                    scroll bar inside the right boundary of the
                                    record.
                                    0 = Draw vertical scroll bar.
                                    1 = Do not draw vertical scroll bar.
   fNoHorzScroll        Bit  18     Tells HexEdit whether to draw a horizontal
                                    scroll bar inside the lower boundary of the
                                    record.
                                    0 = Draw horizontal scroll bar.
                                    1 = Do not draw horizontal scroll bar.
   fNoGrow              Bit  17     Tells HexEdit whether to draw a grow box
                                    at the lower-left corner of the record.
                                    0 = Draw grow control.
                                    1 = Do not draw grow control.
   Reserved             Bits 16-0   Must be set to 0.

$1E - hexDataDescriptor Word - Input hex data descriptor that defines the
                               reference type for the inital hex data.

                        Bits 15-2   Must be set to 0.
                        Bits  1-0   Defines type of reference in hexDataRef.
                                    00 = Data reference is by pointer
                                    01 = Data reference is by handle
                                    10 = Data reference is by resource ID
                                         (resource type of $4845 = 'HE')
                                    11 = Invalid value

$20 - hexDataRef        Word - Reference to original hex data. If no hex data is
                               being supplied, set this field to NIL.

$24 - hexDataLength     Long - If hexDataRef is a pointer to the initial data,
                               this field must contain the length of the initial
                               data. For other data types, this field is
                               ignored.

$28 - vertAmount        Word - The number of pixels to scroll whenever the user
                               presses the up or down arrow on the vertical
                               scroll bar. To use the default value of 9, set
                               this field to NULL.

$2A - horzAmount        Word - The number of pixels to scroll whenever the user
                               presses the left or right arrow on the horizontal
                               scroll bar. To use the default value of xx, set
                               this field to NULL.

$2C - maxBytes          Long - Maximum number of bytes allowed to be entered
                               into this record.

HERecord layout:
================

$00 - ctlNext           Long - Must be set to NIL.

$04 - cltOwner          Long - Must be set to NIL.

$08 - ctlRect           Rect - Must be set to NULL.

$10 - ctlFlag           Byte - Must be set to NULL.

$11 - ctlHilite         Byte - Must be set to NULL.

$12 - ctlValue          Word - Must be set to NULL.

$14 - ctlProc           Long - Must be set to NIL.

$18 - ctlAction         Long - Must be set to NIL.

$1C - ctlData           Long - Must be set to NULL.

$20 - ctlRefCon         Long - Reserved for application use.

$24 - ctlColor          Long - Must be set to NIL.

$28 - hexFlags          Long - Specific HexEdit control flags. Valid values for
                               hexFlags are as follows:

   fNotControl          Bit  31     Must be set to 1.
   fOffsetType          Bits 30-29  Defines the type of byte offsets drawn just
                                    inside the left side of the boundary rect.
                                    00 = Do not draw any offsets
                                    01 = Draw short offsets ($wxyz)
                                    10 = Draw long offsets  ($uvwxyz)
                                    11 = Invalid value
   Reserved             Bit  28     Must be set to 0.
   fNoScroll            Bit  27     Controls user access to scrolling.
                                    0 = Allow scrolling
                                    1 = Do not allow either manual or automatic
                                        scrolling
   fReadOnly            Bit  26     Restricts the text in the record to read-
                                    only (copying from the record is still
                                    allowed).
                                    0 = Editing permited
                                    1 = No editing permitted
   Reserved             Bit  25     Must be set to 0.
   fTabSwitch           Bit  24     Must be set to 0.
   fDrawBounds          Bit  23     Tells HexEdit whether to draw a box around
                                    the edit record, just inside the rect. The
                                    pen for this box is two pixels wide by one
                                    pixel high.
   fDataType            Bits 22-21  Tells HexEdit what kind of data is to be
                                    displayed.
                                    00 = Invalid value
                                    01 = Draw only hex data
                                    10 = Draw only ASCII data
                                    11 = Draw both data types
   fDisableSelection    Bit  20     Controls whether the user can select text.
                                    0 = User can select text.
                                    1 = User cannot select text.
   fNoVertScroll        Bit  19     Tells HexEdit whether to draw a vertical
                                    scroll bar inside the right boundary of the
                                    record.
                                    0 = Draw vertical scroll bar.
                                    1 = Do not draw vertical scroll bar.
   fNoHorzScroll        Bit  18     Tells HexEdit whether to draw a horizontal
                                    scroll bar inside the lower boundary of the
                                    record.
                                    0 = Draw horizontal scroll bar.
                                    1 = Do not draw horizontal scroll bar.
   fNoGrow              Bit  17     Tells HexEdit whether to draw a grow box
                                    at the lower-left corner of the record.
                                    0 = Draw grow control.
                                    1 = Do not draw grow control.
   Reserved             Bits 16-0   Must be set to 0.

$2C - hexDataRef        Long - Handle to current hex data.

$30 - maxBytes          Long - Maximum number of bytes allowed to be entered
                               into this record.

$34 - Reserved          Long - Must be set to NULL.

$38 - ctlID             Long - Unique ID for HexEdit records. The application
                               can use it to identify a particular HexEdit
                               record uniquely.

$3C - ctlMoreFlags      Word - Must be set to NULL.

$3E - ctlVersion        Word - Must be set to NULL.

$40 - selectionStart    Long - Starting byte offset for the current selection.
                               Must always be less than or equal to the field
                               selectionEnd.

$44 - selectionEnd      Long - Ending byte offset for the current selection.
                               Must always be greater or equal to the field
                               selectionStart.

$48 - selectionActive   Word - State information concerning the current
                               selection, as defined by selectionStart and
                               selectionEnd. This word is True if the selection
                               is active, and False if not. For example, this
                               word is used during window updates to determine
                               if the current selection should be drawn.

$4A - selectionState    Word - Flag indicating whether the current selection
                               range is visible within the current window. True
                               if it is, False if it is not. For example, this
                               word is used during window updates to determine
                               if the current selection should be drawn.

$4C - selectionSide     Word - Whether the current selection was made within the
                               hex side of the display or on the ASCII side.

$4E - caretTime         Long - The last time the caret switched states,
                               expressed in system ticks.

$52 - vertScrollHand    Long - Handle to the vertical scroll bar control, if
                               specified by hexFlags.

$56 - vertScrollLoc     Long - Current position of the vertical scroll bar, in
                               units defined by vertScrollAmount.

$5A - vertScrollMax     Long - Maximum allowable vertical scroll, in units
                               defined by vertScrollAmount.

$5E - vertScrollAmount  Word - The number of pixels to scroll whenever the user
                               presses the up or down arrow on the vertical
                               scroll bar. To use the default value of 9, set
                               this field to NULL.

$60 - horzScrollHand    Long - Handle to the horizontal scroll bar control, if
                               specified by hexFlags.

$64 - horzScrollLoc     Long - Current position of the horizontal scroll bar, in
                               units defined by horzScrollAmount.

$68 - horzScrollMax     Long - Maximum allowable horizontal scroll, in units
                               defined by horzScrollAmount.

$6C - horzScrollAmount  Word - The number of pixels to scroll whenever the user
                               presses the left or right arrow on the horizontal
                               scroll bar. To use the default value of xx, set
                               this field to NULL.

$6E - growBoxHand       Long - Handle to the grow box control, if specified by
                               hexFlags.

$72 - clickRect         Rect - Boundary rectangle for mouse events.

$7A - clickTime         Long - System tick count when mouse was last released.

$7E - clickCount        Word - Type of last click. 1=Single, 2=Double, 3=Triple.

$80 - lastClick         Long - Location of last mouse click.

$84 - anchorPoint       Long - The byte offset from which the current selection
                               was started. When HexEdit expands the current
                               selection it does so from anchorPoint, not from
                               selectionStart or selectionEnd.


     Well, these are just some prelmin specs. Anything can and will change. Any
comments? Too ambitious?

Jimurphy
